package chapter5;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description:  读入数字求和求平均值
 * Date:2021/4/3
 * ***************************************************************
 */
public class exc5_1 {
	public static void main(String[] args) {
		Scanner input=new Scanner (System.in);
		int n1=0,n2=0; 	//	正数个数和负数个数
		double sum=0;
		System.out.print("Enter an integer , the input  ends  if it is 0: ");
		int data=input.nextInt();
		
		if(data==0) {
			System.out.println("No numbers are entered except 0");
		}
		
		while(data!=0) {
			if(data>0) {
				n1++;
			}else {
				n2++;
			}
			sum+=data;
			data=input.nextInt();
		}
		
		
		
		System.out.printf("The number of positives is %d .\n",n1);
		System.out.printf("The number of negatives is %d .\n",n2);
		System.out.printf("The total is %.1f \n", sum);
		System.out.printf("The average is %.2f\n", sum/(1.0*(n1+n2)));
		
		
		
	}

}
